// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "WinstonLogger.h"
#include "CameraManager.h"
#include "EmptyLandGameMode.generated.h"

/**
 * 游戏模式类，控制游戏的主要逻辑和规则
 */
UCLASS()
class EMPTYLAND_API AEmptyLandGameMode : public AGameModeBase
{
    GENERATED_BODY()

public:
    // 构造函数
    AEmptyLandGameMode();

protected:
    // 游戏开始时调用
    virtual void BeginPlay() override;

public:
    // 当玩家控制器已连接时调用
    virtual void PostLogin(APlayerController* NewPlayer) override;

    /**
     * 获取地形管理器
     * @return 地形管理器指针
     */
    UFUNCTION(BlueprintCallable, Category = "Game Mode")
    class ATerrainManager* GetTerrainManager() const;

    /**
     * 获取相机管理器
     * @return 相机管理器指针
     */
    UFUNCTION(BlueprintCallable, Category = "Game Mode")
    ACameraManager* GetCameraManager() const;

protected:
    // 地形管理器类
    UPROPERTY(EditDefaultsOnly, Category = "Game Systems", meta = (AllowPrivateAccess = "true"))
    TSubclassOf<class ATerrainManager> TerrainManagerClass;

    // 地形管理器实例
    UPROPERTY(Transient, BlueprintReadOnly, Category = "Game Systems", meta = (AllowPrivateAccess = "true"))
    class ATerrainManager* TerrainManagerInstance;

    // 相机管理器类
    UPROPERTY(EditDefaultsOnly, Category = "Game Systems", meta = (AllowPrivateAccess = "true"))
    TSubclassOf<ACameraManager> CameraManagerClass;

    // 相机管理器实例
    UPROPERTY(Transient, BlueprintReadOnly, Category = "Game Systems", meta = (AllowPrivateAccess = "true"))
    ACameraManager* CameraManagerInstance;

private:
    /**
     * 初始化地形系统
     */
    void InitializeTerrainSystem();

    /**
     * 初始化游戏系统
     */
    void InitializeGameSystems();
};